﻿using Mobile.Controllers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
using Mobile.Models;
using System.Web.Mvc;

namespace Mobile.Tests
{
    
    
    /// <summary>
    ///This is a test class for SongControllerTest and is intended
    ///to contain all SongControllerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SongControllerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for SongController Constructor
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void SongControllerConstructorTest()
        {
            SongController target = new SongController(); //initialize controller
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for Create
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void CreateTest()
        {
            SongController target = new SongController(); // Initialize SongController
            Song song = new Song(); // Create a new song object
            song.Artist = "Tupac";
            song.ID = "12345";
            song.Title = "Changes";
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize to view object we expect to get back
            ActionResult actual;
            actual = target.Create(song);
            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);
            //Check whether return value is null
            Assert.IsNotNull(actual);
        }



        /// <summary>
        ///A test for Deleting of song from DB
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void DeleteTest()
        {
            SongController target = new SongController(); // Initialize controller
            int id = 0; //initialize to an id of a song to delete
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize to view type
            ActionResult actual;
            actual = target.Delete(id);
            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);
            //Check whether return value is null
            Assert.IsNotNull(actual);

            //In future when we are comfortable with web service interaction, want to test that song actually gets deleted
        }

        /// <summary>
        ///A test for Song Details
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void DetailsTest()
        {
            SongController target = new SongController(); // Initialize blank controller
            int id = 0; // Initialize a song id for testing
            ActionResult expected = new System.Web.Mvc.ViewResult(); // TODO: Initialize to an appropriate value
            ActionResult actual;
            actual = target.Details(id);
            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);
            //Check whether return value is null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for Dispose
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        [DeploymentItem("Mobile.dll")]
        public void DisposeTest()
        {
            SongController_Accessor target = new SongController_Accessor(); // initialize to generic accessor
            bool disposing = false; //initialize to not dispose
            target.Dispose(disposing);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for Edit
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void EditTest()
        {
            SongController target = new SongController(); // initialize empty controller
            int id = 0; // initialize song id
            ActionResult expected = new System.Web.Mvc.ViewResult(); // initialize to view we are expecting
            ActionResult actual;
            actual = target.Edit(id);
            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);
            //Check whether return value is null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for Edit
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void EditTestWithSongParam()
        {
            SongController target = new SongController(); // Initialize to blank controller
            Song song = new Song(); // initialize a song object
            song.Artist = "Johnny Cash";
            song.Title = "Walk the Line";
            ActionResult expected = new System.Web.Mvc.ViewResult(); // Initialize to view we are looking for
            ActionResult actual;
            actual = target.Edit(song);
            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);
            //Check whether return value is null
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for Index
        ///</summary>
        [TestMethod()]
        //[HostType("ASP.NET")]
        //[AspNetDevelopmentServerHost("C:\\Users\\Jim\\Documents\\Senior Year\\CS 638\\CurrentSolution\\TFS_Solution\\Mobile\\Mobile", "/")]
        [UrlToTest("http://localhost:1034/")]
        public void IndexTest()
        {
            SongController target = new SongController(); // Initialize song controller
            ActionResult expected = new System.Web.Mvc.ViewResult(); // initialize to view like we expected
            ActionResult actual;
            actual = target.Index();
            //We want to make sure we get a view back, so we will test that
            Type expectedType = expected.GetType();
            Type actualType = actual.GetType();
            Assert.AreEqual(expectedType, actualType);
            //Check whether return value is null
            Assert.IsNotNull(actual);
        }
    }
}
